package org.medicalinstrument.action;

import org.medicalinstrument.service.PurchaseOrderService;

import java.sql.SQLException;

import static com.opensymphony.xwork2.Action.SUCCESS;
import static java.util.jar.Pack200.Packer.ERROR;

public class PurchaseOrderAction {
    private String returnString;
    private String name;
    private String tele;
    private String state;
    private String timein;
    private String timeout;
    private String custPhone;
    private String getOrConsigee;
    private String orderState;
    private String consigeeAddr;
    private String orderId;
    private String accountNo;
    private String productQR;


    public String getProductQR() {
        return productQR;
    }

    public void setProductQR(String productQR) {
        this.productQR = productQR;
    }

    public String getAccountNo() {
        return accountNo;
    }

    public void setAccountNo(String accountNo) {
        this.accountNo = accountNo;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getCustPhone() {
        return custPhone;
    }

    public void setCustPhone(String custPhone) {
        this.custPhone = custPhone;
    }

    public String getGetOrConsigee() {
        return getOrConsigee;
    }

    public void setGetOrConsigee(String getOrConsigee) {
        this.getOrConsigee = getOrConsigee;
    }

    public String getOrderState() {
        return orderState;
    }

    public void setOrderState(String orderState) {
        this.orderState = orderState;
    }

    public String getConsigeeAddr() {
        return consigeeAddr;
    }

    public void setConsigeeAddr(String consigeeAddr) {
        this.consigeeAddr = consigeeAddr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTele() {
        return tele;
    }

    public void setTele(String tele) {
        this.tele = tele;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getTimein() {
        return timein;
    }

    public void setTimein(String timein) {
        this.timein = timein;
    }

    public String getTimeout() {
        return timeout;
    }

    public void setTimeout(String timeout) {
        this.timeout = timeout;
    }

    public String getReturnString() {  return returnString; }
    public void setReturnString(String returnString) { this.returnString = returnString; }
    PurchaseOrderService pos = new PurchaseOrderService();
/**
 * @desc ： 得到所有订单
 * @author : llh
 * @param :
 * @return :
**/
    public String getAllPurchaseOrderList() throws Exception {
        System.out.println("act");
        returnString = pos.getAllOrder();
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }
    /**
     * @desc ： 条件查询
     * @author : llh
     * @param : accountNo,timein,timeout
     * @return :
    **/
    public String optionSelect() throws SQLException {
        returnString = pos.optionSelect(accountNo,timein,timeout);
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }
    /**
     * @desc ： 订单修改
     * @author : llh
     * @param :
     * @return :
    **/
    public String modifyOrder() throws SQLException {
        System.out.println("123");
        returnString = pos.modifyOrder(custPhone,getOrConsigee,state,consigeeAddr,orderId,accountNo,productQR);
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }
    /**
     *@Author llh
     *@Description 订单删除
     *@Date 10:19 2019/3/27
     *@Modify by 
     *@Version 1.0
     */
    public String delete() throws SQLException {
        returnString = pos.delete(orderId,accountNo);
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }

    }
    /**
     * @author cirly
     * @description 查询客户订单
     * @date 2019-04-16 19:21
     * @param
     * @return java.lang.String
     * @modify by ：
     */
    public String getPurchaseOrder() throws SQLException{
        System.out.println(accountNo);
        returnString = pos.geCustomerOrder(accountNo);

        if(returnString.equals("purchase_null")){
            return ERROR;
        }else{
            return SUCCESS;
        }
    }
    /**
     *@Author llh
     *@Description 订单详情
     *@Date 10:19 2019/3/27
     *@Modify by
     *@Version 1.0
     */
    public String getOrderDetails() throws SQLException {
        System.out.println("gfu");
        returnString = pos.getOrderDetail(orderId, accountNo);
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }
    /**
     * @desc ： 条件查询
     * @author : llh
     * @param : accountNo,timein,timeout
     * @return :
     **/
    public String optionsSelect() throws SQLException {
        System.out.println("ss");
        returnString = pos.optionsSelect(name,accountNo,timein,timeout);
        if (returnString.equals("nopurchaseorder")) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }

}

